<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page language="java" pageEncoding="ISO-8859-1" contentType="text/html; charset=ISO-8859-1" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> 
	<title>Sql Data Generator</title>
	<script type="text/javascript">
		function run(){
			document.getElementsByName("applet")[1].generateScript(
				document.getElementById("databaseDriver").value,
				document.getElementById("databaseUrl").value,
				document.getElementById("userName").value,
				document.getElementById("password").value,
				document.getElementById("sqlStatement").value
			);
		}
		var callback = {
			onSuccess: function(result){
				document.getElementById("script").value = result.resultScript;
			},
			onError: function(ex){
				document.getElementById("script").value = "";
				alert("Error: " + ex);
			}
		};
	</script>
</head>
<body>
	<form id="form">
		<p>Welcome to SqlDataGenerator!</p>
		<hr />
		<p>
			<label>Connection Driver:</label>
			<select id="databaseDriver">
				<option>net.sourceforge.jtds.jdbc.Driver</option>
			</select>
		</p>
		<p>
			<label>Connection URL:</label>
			<input id="databaseUrl" value="jdbc:jtds:sqlserver://127.0.0.1:1433/SQLEXPRESS;DatabaseName=pdv" />
		</p>
		<p>
			<label>User Name:</label>
			<input id="userName" value="sa" />
		</p>
		<p>
			<label>Password:</label>
			<input id="password" value="sa" />
		</p>
		<hr />
		<p>
			<label>SQL:</label> 
			<textarea id="sqlStatement"></textarea>
			<input type="submit" onclick="setTimeout(run,0); return false" />
		</p>
		<hr />
		<p>
			<label>Generated Script:</label>
			<textarea id="script"></textarea>
		</p>
		<br />
	</form>
	<jsp:plugin
		name="applet" 
		type="applet" 
		codebase=""
		code="com.googlecode.sqldatagenerator.applet.SqlDataGeneratorApplet"
		archive="applet/sqldatagenerator-applet-1.0.0.jar"
		width="100px"
		height="100px">
		<jsp:fallback> 
	          <p>Unable to load applet</p> 
	   	</jsp:fallback>
	</jsp:plugin>
</body>
</html>